from django.shortcuts import render_to_response, get_object_or_404
from django.views.generic import list_detail
from models import *

def project_list(request, page='default'):
    """
    A list of projects for a page.
    """
    page = get_object_or_404(Page, slug__iexact=page)
    
    return list_detail.object_list(
        request,
        queryset = page.project_set.public(),
        extra_context = {'page': page},
        template_object_name = 'project',
    )

def project_detail(request, slug):
    """
    A project on a page.
    """
    return list_detail.object_detail(
        request,
        template_object_name = 'project',
        queryset = Project.objects.public(),
        slug = slug,
    )
